<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="java.util.Enumeration"%>
<%@ include file="/WEB-INF/view/include.jsp"%>
<%@page
	import="ae.pcfc.etks.online.itworx.ehs.web.constants.GlobalConstants"%>

<script>
	function submitFnpForm(fromId) {
		
		var selObj = document.getElementById('fnpServices');
		
		if(selObj.selectedIndex >-1)
			{
				document.forms[fromId].submit();
			}
		else
			{
			alert('<spring:message code="error.fnp.service.required" />');
			}
	}
</script>
<div class="t_tmiddle-right">

	<form:form id="fnpServicesFrm" modelAttribute="fnp" method="POST"
		action="admin/fnpMapping.htm?type=feesMapping">

		<div style="color:#ED0000;font-size:12px;margin:0 0 10px 10px" id="errorDiv">
			<spring:bind path="fnp.*">
				<c:forEach items="${errors.globalErrors}" var="error">
					<c:out value="${error}" />
					<br />
				</c:forEach>
			</spring:bind>
		</div>
		
		<div style="color:#ED0000;font-size:12px;margin:0 0 10px 10px" id="errorDiv">
			<spring:bind path="fnp.*">
				<c:forEach items="${status.errorMessages}" var="error">
					<c:out value="${error}" />
					<br />
				</c:forEach>
			</spring:bind>
		</div>

		<div class="t_search_heading">Services List</div>
		<div class="t_form-left" id="services_list">
			<label class="multiple_selection_label"> Services List:</label>
			<form:select id="fnpServices" path="fnpServices" multiple="true" size="5"
				class="multiple">
				<c:forEach var="fnpService" items="${fnpAllServices}">
					<c:set var="isSelected" value="false"/>
					<c:forEach items="${fnp.fnpServices}" var="selectedService">
						<c:if test="${selectedService.serviceId eq fnpService.serviceId}">
						    <c:set var="isSelected" value="true" />
						 </c:if>
					</c:forEach>
										
	        		<option value="${fnpService.serviceId}"  <c:if test="${isSelected}">selected="selected"</c:if> title="${fnpService.fullServiceName}"><c:out value="${fnpService.fullServiceName}"/></option>
	    		</c:forEach>
    		
			</form:select>

			<div class="popup_btn">
				<button type="button" class="btn_bg"
					onclick="submitFnpForm('fnpServicesFrm');">Get Parameters</button>
			</div>
		</div>
	</form:form>

	<div class="brk"></div>

	<form:form id="fnpParametersFrm" modelAttribute="fnp" method="POST"
		action="admin/thankyou.htm?type=feesMapping">
		<c:choose>
			<c:when test="${fnp.parametersExists}">
				<div id="fnp_parameters">
			</c:when>
			<c:otherwise>
				<div id="fnp_parameters" style="display: none">
			</c:otherwise>
		</c:choose>

			<c:forEach items="${fnp.fnpServices}" var="service"
				varStatus="serviceStatus">
				
						<table class="grdView">

						<caption></caption>
						<colgroup>
							<col width="36%" />
							<col width="21%" />
							<col width="21%" />
							<col width="22%" />
						</colgroup>
						<tr>
							<th>Parameters</th>
							<th>Rename (English)</th>
							<th>Rename (Arabic)</th>
							<th>Form Field Mapping</th>
						</tr>
				<c:forEach items="${service.fnpParameters}" var="parameter"
					varStatus="status">
				<c:choose>
				<c:when test="${parameter.dummy == false}">
						<tr ${status.index % 2 == 0 ? 'class="grdAltRow"' : ''}>
							<td>${parameter.name}:</td>
							<td><input
								name="fnpServices[${serviceStatus.index}].fnpParameters[${status.index}].englishName"
								value="${parameter.englishName}" class="fnp_form-fld"
								maxlength="50" /></td>
							<td><input
								name="fnpServices[${serviceStatus.index}].fnpParameters[${status.index}].arabicName"
								value="${parameter.arabicName}" class="fnp_form-fld"
								maxlength="50" /></td>
							<td><select
								name="fnpServices[${serviceStatus.index}].fnpParameters[${status.index}].formMappingField"
								class="fm-opt">
									<option value=""
										<c:if test="${empty parameter.formMappingField}">selected</c:if>>None</option>
									<option value="CompanyNameArabic"
										<c:if test="${parameter.formMappingField eq 'CompanyNameArabic'}">selected</c:if>>Company
										Arabic Name</option>
									<option value="CompanyNameEnglish"
										<c:if test="${parameter.formMappingField eq 'CompanyNameEnglish'}">selected</c:if>>Company
										English Name</option>
									<option value="LicenseNumber"
										<c:if test="${parameter.formMappingField eq 'LicenseNumber'}">selected</c:if>>License
										Number</option>
									<option value="MainEmail"
										<c:if test="${parameter.formMappingField eq 'MainEmail'}">selected</c:if>>Main
										Email</option>
									<option value="Activity"
										<c:if test="${parameter.formMappingField eq 'Activity'}">selected</c:if>>Activity</option>
									<option value="BusinessUnit"
										<c:if test="${parameter.formMappingField eq 'BusinessUnit'}">selected</c:if>>Business
										Unit</option>
									<option value="Location"
										<c:if test="${parameter.formMappingField eq 'Location'}">selected</c:if>>Location</option>
									<option value="Bcc"
										<c:if test="${parameter.formMappingField eq 'Bcc'}">selected</c:if>>Building
										Completiton Certificate No</option>
									<option value="RequestedBy"
										<c:if test="${parameter.formMappingField eq 'RequestedBy'}">selected</c:if>>Requested
										By</option>
									<option value="OptionalMail"
										<c:if test="${parameter.formMappingField eq 'OptionalMail'}">selected</c:if>>Optional
										Email</option>
									<option value="CreationDate"
										<c:if test="${parameter.formMappingField eq 'CreationDate'}">selected</c:if>>Creation
										Date</option>
									<option value="Remarks"
										<c:if test="${parameter.formMappingField eq 'Remarks'}">selected</c:if>>Remarks</option>
									<option value="ContactPersonName"
										<c:if test="${parameter.formMappingField eq 'ContactPersonName'}">selected</c:if>>Contact
										Person</option>
									<option value="Mobile"
									<c:if test="${parameter.formMappingField eq 'Mobile'}">selected</c:if>>Mobile</option>
								<option value="Telephone"
									<c:if test="${parameter.formMappingField eq 'Telephone'}">selected</c:if>>Telephone</option>
								<option value="Fax"
									<c:if test="${parameter.formMappingField eq 'Fax'}">selected</c:if>>Fax</option>
						</select> <input type="hidden"
							name="fnpServices[${serviceStatus.index}].fnpParameters[${status.index}].serviceId"
							value="${parameter.serviceId}" /> <input type="hidden"
							name="fnpServices[${serviceStatus.index}].fnpParameters[${status.index}].name"
							value="${parameter.name}" /> <input type="hidden"
							name="fnpServices[${serviceStatus.index}].fnpParameters[${status.index}].order"
							value="${parameter.order}" /></td>
					</tr>
					</c:when>
					<c:otherwise>
						<tr>
							<td colspan="4">
								<div class="error_dark"><normal><spring:message code="label.fnp.no.parameters.exist"/></normal></div>
							</td>
						</tr>
					</c:otherwise>
					</c:choose>
				</c:forEach>
					</table>
					<div class="brk"></div>
				<input type="hidden"
					name="fnpServices[${serviceStatus.index}].serviceId"
					value="${service.serviceId}" />
			</c:forEach>

		<div id="fm-submit">
			<div class="btn_border">
				<button type="button" class="btn_bg"
					onclick="submitFnpForm('fnpParametersFrm');">Map</button>
			</div>
		</div>
</div>
</form:form>

</div>
<!--Middle Right Close-->